#include <iostream>
#include <queue>
using namespace std;

int grid[5][5];

// 上下左右
int dr[4] = {-1, 1, 0, 0};
int dc[4] = {0, 0, -1, 1};

struct Node {
    int r;
    int c;
};

Node last[5][5];

bool ok(int fr, int fc) {
    if (fr < 0 || fr > 4 || fc < 0 || fc > 4 || grid[fr][fc] == 1) return 0;
    return 1;
}

bool v[5][5];

int main() {
    for (int r = 0; r < 5; r++)
        for (int c = 0; c < 5; c++) cin >> grid[r][c];
    queue<Node> Q;
    Q.push(Node{0, 0});
    last[0][0].r = -1;
    last[0][0].c = -1;
    v[0][0] = 1;
    while (!Q.empty()) {
        int r = Q.front().r;
        int c = Q.front().c;
        Q.pop();
        for (int i = 0; i < 4; i++) {
            int fr = r + dr[i];
            int fc = c + dc[i];
            if (ok(fr, fc) && !v[fr][fc]) {
                v[fr][fc] = 1;
                last[fr][fc].r = r;
                last[fr][fc].c = c;
                Q.push(Node{fr, fc});
            }
        }
    }

    Node ans[10000];
    int cur = 0;
    ans[cur].r = 4;
    ans[cur].c = 4;
    cur++;
    int rr = 4;
    int cc = 4;
    while( rr!=0 || cc!=0){
        ans[cur].r = last[rr][cc].r;
        ans[cur].c = last[rr][cc].c;
        rr = ans[cur].r;
        cc = ans[cur].c;
        cur++;
    }

    for(int i=cur-1;i>=0;i--)
    cout << "(" << ans[i].r << ", " << ans[i].c << ")" << endl;

    return 0;
}